<?php
/**
 * Joomla! 1.5 component Bbits Simple directory
 *
 * @version $Id: view.html.php 2011-07-08 03:53:16 svn $
 * @author Miguel Puig
 * @URL http://miguelpuig.com
 * @package Joomla
 * @subpackage Bbits Simple directory
 * @license GNU/GPL
 *
 * Simple Directory by bittingbits.com
 *
 *
 */
// no direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.model');


class BbitsdModelBusiness extends JModel {
    var $_data;
    var $_query;
    
    function __construct()
    {
        parent::__construct();
    }
    
    function _buildQuery()
    {
        $this->_query = 'SELECT * FROM #__bbitsd_items WHERE published=1';
        return $this->_query;
    }

    
    function getData()
    {
        $this->_buildQuery();
        
        if (empty($this->_data)) {
            $this->_db->setQuery($this->_query);
            $this->_data = $this->_getList($this->_query);
        }
        echo "NANA";
        return $this->_data;
    }
    function getBusinessById()
    {
    	$id = JRequest::getVar('id');
    	$query = 'SELECT * FROM #__bbitsd_items WHERE published=1 AND id='.$id;
    	$this->_db->setQuery($query);
    	$business = $this->_getList($query);
    	return $business[0];
    }    

	function addhit($idbusiness)
	{
		$query = 'UPDATE #__bbitsd_items SET hits=hits+1 WHERE id='.$idbusiness;
        $this->_db->setQuery($query);
        $this->_db->query();
	}
    
    function getModel()
    {
        return $this;
    }
    

}
?>
